package com.rz.htk.postal.controller;

import com.rz.core.kit.RespKit;
import com.rz.core.resp.ResultResp;
import com.rz.htk.postal.entity.ExpressCode;
import com.rz.htk.postal.entity.ExpressCodeRecord;
import com.rz.htk.postal.service.IExpressCodeRecordService;
import com.rz.htk.postal.service.IExpressCodeService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @ClassName ExpressCodeController
 * @Description 快递单号Controller
 * @Author maweiyue
 * @Date 2019/3/27 18:36
 */
@RestController
@RequestMapping("expressCode")
public class ExpressCodeController {

    @Resource
    private IExpressCodeService expressCodeService;

    @Resource
    private IExpressCodeRecordService expressCodeRecordService;

    @PostMapping("/getPage")
    public ResultResp getPage(@RequestBody ExpressCode expressCode){
        return RespKit.success(expressCodeService.getPage(expressCode));
    }

    /**
     * 获取快递单号导入记录
     * @param expressCodeRecord
     * @return
     */
    @PostMapping("/getPageExpressCodeRecords")
    public ResultResp getPageExpressCodeRecords(@RequestBody ExpressCodeRecord expressCodeRecord){
        return RespKit.success(expressCodeRecordService.getExpressCodeRecords(expressCodeRecord));
    }

    /**
     * 导入快递单号
     * @return
     */
    @PostMapping("/importExpressCode")
    public ResultResp importExpressCode(ExpressCode expressCode, MultipartFile file){
        return RespKit.success(this.expressCodeService.importExpressCode(expressCode, file));
    }

    /**
     * 从系统快递单号库中获取一个单号
     * @return
     */
    @PostMapping("/getExpressCode")
    public ResultResp getExpressCode(@RequestBody ExpressCode expressCode){
        return RespKit.success(this.expressCodeService.getExpressCode(expressCode));
    }
}
